package com.gxa.cddx.www.spting_ai.util;

/**
 * @author liye
 * @date 2025/10/17 9:06
 * @description:  结果： 操作的结果是什么
 */
public class R {
    //code:状态码   msg ：信息   data： 数据
    private Integer code;
    private String msg;
    private Object data;

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    /**
     * 创建一个结果:成功
     * @return
     */
    public static R ok(){
        R r = new R();
        r.setCode(200);
        r.setMsg("操作成功");
        r.setData(null);
        return r;
    }
    public static R ok(Object data){
        R r = new R();
        r.setCode(200);
        r.setMsg("操作成功");
        r.setData(data);
        return r;
    }
    /**
     * 创建一个结果:失败
     */
    public static R error(){
        R r = new R();
        r.setCode(5000);
        r.setMsg("操作失败");
        r.setData(null);
        return r;
    }
    public static R error(String msg){
        R r = new R();
        r.setCode(5000);
        r.setMsg(msg);
        r.setData(null);
        return r;
    }
}
